package com.example.mobile2021606170hsy0406homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Main3Activity extends AppCompatActivity {
    String a,b,c;
    private TextView tvMainTitle;
    private TextView tvMainMax;
    private TextView tvMainAskfor;
    private TextView tvMainA;
    private EditText edtTxtMainFigure;
    private TextView tvMainB;
    private EditText edtTxtMainFigure1;
    private TextView tvMainC;
    private EditText edtTxtMainFigure2;
    private Button btMainResult;
    private EditText edtTxtMainResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        initView();
    }

    private void initView() {
        tvMainTitle = findViewById(R.id.tv_main_title);
        tvMainMax = findViewById(R.id.tv_main_max);
        tvMainAskfor = findViewById(R.id.tv_main_askfor);
        tvMainA = findViewById(R.id.tv_main_a);
        edtTxtMainFigure = findViewById(R.id.edtTxt_main_figure);
        tvMainB = findViewById(R.id.tv_main_b);
        edtTxtMainFigure1 = findViewById(R.id.edtTxt_main_figure1);
        tvMainC = findViewById(R.id.tv_main_c);
        edtTxtMainFigure2 = findViewById(R.id.edtTxt_main_figure2);
        btMainResult = findViewById(R.id.bt_main_result);
        edtTxtMainResult = findViewById(R.id.edtTxt_main_result);
    }

    public void resultonClik(View view) {
         a = edtTxtMainFigure.getText().toString();
         b = edtTxtMainFigure1.getText().toString();
         c = edtTxtMainFigure2.getText().toString();
String[] arr={a,b,c};
if(a.length()==0||b.length()==0||c.length()==0){
    Toast.makeText(Main3Activity.this,"请输入数字", Toast.LENGTH_SHORT).show();
    }else {
int[] arr2 = {Integer.parseInt(a),Integer.parseInt(b),Integer.parseInt(c)};
int max= arr2[0];
for(int i =  1; i < arr2.length;i++){
    if ((arr2[i])>max){
        max = arr2[i];
        edtTxtMainResult.setText(String.valueOf((arr2[i])));
    }
}
}
    }
}